

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>块设备基础命令 &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/doctools.js"></script>
        <script src="../../_static/sphinx_highlight.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="Ceph 块设备运维" href="../rbd-operations/" />
    <link rel="prev" title="Ceph 块设备" href="../" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../">Ceph 块设备</a></li>
      <li class="breadcrumb-item active">块设备基础命令</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../../_sources/rbd/rados-rbd-cmds.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../" class="icon icon-home"> Ceph
          

          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephfs/">Ceph 文件系统</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../">Ceph 块设备</a><ul class="current">
<li class="toctree-l2 current"><a class="current reference internal" href="#">基本命令</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id2">创建一个块设备存储池</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id3">创建一个块设备用户</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id4">创建块设备映像</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id5">罗列块设备映像</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id6">检索映像信息</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id7">调整块设备映像尺寸</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id8">增加块设备映像的尺寸</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id9">减小块设备映像的尺寸</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#id10">删除块设备映像</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id11">从一个存储池删除块设备</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id12">从一个存储池“延迟删除”块设备</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id13">从存储池删除已延期的块设备</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#id14">块设备映像的恢复</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id15">恢复指定存储池里的块设备映像</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id16">恢复映像时重命名它</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../rbd-operations/">运维</a></li>
<li class="toctree-l2"><a class="reference internal" href="../rbd-integrations/">对接</a></li>
<li class="toctree-l2"><a class="reference internal" href="../man/">手册页</a></li>
<li class="toctree-l2"><a class="reference internal" href="../api/">APIs</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../monitoring/">监控概览</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../hardware-monitoring/">硬件监控</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <section id="id1">
<h1>块设备基础命令<a class="headerlink" href="#id1" title="Permalink to this heading"></a></h1>
<p id="index-0"><code class="docutils literal notranslate"><span class="pre">rbd</span></code> 命令可用于创建、罗列、自查和删除块设备映像，也可克隆映像、创建快照、回滚快照、查看快照等等。 <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 命令用法详情见
<a class="reference external" href="../../man/8/rbd/">RBD – 管理 RADOS 块设备映像</a>。</p>
<div class="admonition important">
<p class="admonition-title">Important</p>
<p>要使用 Ceph 块设备命令，你必须有相应的集群访问权限。</p>
</div>
<section id="id2">
<h2>创建一个块设备存储池<a class="headerlink" href="#id2" title="Permalink to this heading"></a></h2>
<ol class="arabic">
<li><p>在管理节点上，用 <code class="docutils literal notranslate"><span class="pre">ceph</span></code> 工具<a class="reference external" href="../../rados/operations/pools/#create-a-pool">创建一个存储池</a>。</p></li>
<li><p>在管理节点上，用 <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 工具初始化这个存储池以用于 RBD：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><style type="text/css">
span.prompt1:before {
  content: "$ ";
}
</style><span class="prompt1">rbd<span class="w"> </span>pool<span class="w"> </span>init<span class="w"> </span>&lt;pool-name&gt;</span>
</pre></div></div><div class="admonition note">
<p class="admonition-title">Note</p>
<p>没指定存储池名字时， <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 工具会假设默认的存储池名字是 rbd 。</p>
</div>
</li>
</ol>
</section>
<section id="id3">
<h2>创建一个块设备用户<a class="headerlink" href="#id3" title="Permalink to this heading"></a></h2>
<p>如果不指定用户名， <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 命令默认将使用 <code class="docutils literal notranslate"><span class="pre">admin</span></code> 用户 ID 访问 Ceph 集群。
这个 ID 有拥有集群的所有管理权限。
我们建议你用一个权限较少的 Ceph 用户 ID 访问 Ceph 集群，
而不是用 <code class="docutils literal notranslate"><span class="pre">admin</span></code> 访问。
我们把这样的非 <code class="docutils literal notranslate"><span class="pre">admin</span></code> Ceph 用户 ID 叫作“块设备用户”或“Ceph 用户”。</p>
<p>要 <a class="reference external" href="../../rados/operations/user-management#add-a-user">创建一个 Ceph 用户</a> ，用 <code class="docutils literal notranslate"><span class="pre">ceph</span> <span class="pre">auth</span> <span class="pre">get-or-create</span></code> 命令，
再指定 Ceph 用户 ID 名、监视器能力、和 OSD 能力：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>auth<span class="w"> </span>get-or-create<span class="w"> </span>client.<span class="o">{</span>ID<span class="o">}</span><span class="w"> </span>mon<span class="w"> </span><span class="s1">&#39;profile rbd&#39;</span><span class="w"> </span>osd<span class="w"> </span><span class="s1">&#39;profile {profile name} [pool={pool-name}][, profile ...]&#39;</span><span class="w"> </span>mgr<span class="w"> </span><span class="s1">&#39;profile rbd [pool={pool-name}]&#39;</span></span>
</pre></div></div><p>例如，要创建一个名为 <code class="docutils literal notranslate"><span class="pre">qemu</span></code> 的用户 ID ，
有 <code class="docutils literal notranslate"><span class="pre">vms</span></code> 存储池的读写权限、
和 <code class="docutils literal notranslate"><span class="pre">images</span></code> 存储池的只读权限，执行命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">ceph<span class="w"> </span>auth<span class="w"> </span>get-or-create<span class="w"> </span>client.qemu<span class="w"> </span>mon<span class="w"> </span><span class="s1">&#39;profile rbd&#39;</span><span class="w"> </span>osd<span class="w"> </span><span class="s1">&#39;profile rbd pool=vms, profile rbd-read-only pool=images&#39;</span><span class="w"> </span>mgr<span class="w"> </span><span class="s1">&#39;profile rbd pool=images&#39;</span></span>
</pre></div></div><p><code class="docutils literal notranslate"><span class="pre">ceph</span> <span class="pre">auth</span> <span class="pre">get-or-create</span></code> 命令的输出是指定用户的密钥环，
可以写入 <code class="docutils literal notranslate"><span class="pre">/etc/ceph/ceph.client.{ID}.keyring</span></code> 。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>使用 <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 命令的时候可以用 <code class="docutils literal notranslate"><span class="pre">--id</span> <span class="pre">{id}</span></code> 可选参数指定 Ceph 用户 ID 。</p>
</div>
</section>
<section id="id4">
<h2>创建块设备映像<a class="headerlink" href="#id4" title="Permalink to this heading"></a></h2>
<p>把块设备加入某节点之前，你得先在 <a class="reference internal" href="../../glossary/#term-28"><span class="xref std std-term">Ceph 存储集群</span></a>中给它创建一个映像。
创建一个块设备映像，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>create<span class="w"> </span>--size<span class="w"> </span><span class="o">{</span>megabytes<span class="o">}</span><span class="w"> </span><span class="o">{</span>pool-name<span class="o">}</span>/<span class="o">{</span>image-name<span class="o">}</span></span>
</pre></div></div><p>例如，要在 <code class="docutils literal notranslate"><span class="pre">swimmingpool</span></code> 存储池中创建一个名为 <code class="docutils literal notranslate"><span class="pre">bar</span></code> 、大小为 1GB 的映像，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>create<span class="w"> </span>--size<span class="w"> </span><span class="m">1024</span><span class="w"> </span>swimmingpool/bar</span>
</pre></div></div><p>如果创建映像时不指定存储池，它将使用默认的 <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 存储池。例如，下面的命令将在默认的 <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 存储池中创建一个大小为 1GB 、名为 <code class="docutils literal notranslate"><span class="pre">foo</span></code> 的映像：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>create<span class="w"> </span>--size<span class="w"> </span><span class="m">1024</span><span class="w"> </span>foo</span>
</pre></div></div><div class="admonition note">
<p class="admonition-title">Note</p>
<p>指定此存储池前必须先创建它，详情见<a class="reference external" href="../../rados/operations/pools">存储池</a>。</p>
</div>
</section>
<section id="id5">
<h2>罗列块设备映像<a class="headerlink" href="#id5" title="Permalink to this heading"></a></h2>
<p>要罗列 <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 存储池中的块设备，执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>ls</span>
</pre></div></div><div class="admonition note">
<p class="admonition-title">Note</p>
<p><code class="docutils literal notranslate"><span class="pre">rbd</span></code> 是默认存储池名字，
而 <code class="docutils literal notranslate"><span class="pre">rbd</span> <span class="pre">ls</span></code> 就罗列默认存储池里的块设备。</p>
</div>
<p>罗列某个特定存储池中的块设备，执行下列命令，
用存储池名字替换掉 <code class="docutils literal notranslate"><span class="pre">{poolname}</span></code> ：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>ls<span class="w"> </span><span class="o">{</span>poolname<span class="o">}</span></span>
</pre></div></div><p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>ls<span class="w"> </span>swimmingpool</span>
</pre></div></div><p>要罗列 <code class="docutils literal notranslate"><span class="pre">rbd</span></code> 存储池内延期删除（ deferred delete ）的块设备，
用此命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>trash<span class="w"> </span>ls</span>
</pre></div></div><p>要罗列指定存储池内延期删除的块设备，用下列命令，
需把 <code class="docutils literal notranslate"><span class="pre">{poolname}</span></code> 替换成这个存储池的名字：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>trash<span class="w"> </span>ls<span class="w"> </span><span class="o">{</span>poolname<span class="o">}</span></span>
</pre></div></div><p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>trash<span class="w"> </span>ls<span class="w"> </span>swimmingpool</span>
</pre></div></div></section>
<section id="id6">
<h2>检索映像信息<a class="headerlink" href="#id6" title="Permalink to this heading"></a></h2>
<p>查看一个指定映像的信息，执行下列命令，用 <code class="docutils literal notranslate"><span class="pre">{image-name}</span></code> 替换映像名字：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>info<span class="w"> </span><span class="o">{</span>image-name<span class="o">}</span></span>
</pre></div></div><p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>info<span class="w"> </span>foo</span>
</pre></div></div><p>查看某存储池内一映像的信息，执行下列命令。用 <code class="docutils literal notranslate"><span class="pre">{image-name}</span></code> 替换掉映像名字、用 <code class="docutils literal notranslate"><span class="pre">{pool-name}</span></code> 替换掉存储池名字：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>info<span class="w"> </span><span class="o">{</span>pool-name<span class="o">}</span>/<span class="o">{</span>image-name<span class="o">}</span></span>
</pre></div></div><p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>info<span class="w"> </span>swimmingpool/bar</span>
</pre></div></div><div class="admonition note">
<p class="admonition-title">Note</p>
<p>还有别的命名惯例，但是可能和这里叙述的有冲突。
比如， <code class="docutils literal notranslate"><span class="pre">userid/&lt;uuid&gt;</span></code> 是个 RBD 映像的名字，
而这样的名字（至少）可能有歧义。</p>
</div>
</section>
<section id="id7">
<h2>调整块设备映像尺寸<a class="headerlink" href="#id7" title="Permalink to this heading"></a></h2>
<p><a class="reference internal" href="../../glossary/#term-2"><span class="xref std std-term">Ceph 块设备</span></a>映像是瘦接口设备，只有在你开始写入数据时它们才会占用物理空间。
然而，它们都有最大容量，就是你用 <code class="docutils literal notranslate"><span class="pre">--size</span></code> 选项设置的。
如果你想增加（或减小） Ceph 块设备映像的最大尺寸，执行下列命令：</p>
<section id="id8">
<h3>增加块设备映像的尺寸<a class="headerlink" href="#id8" title="Permalink to this heading"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>resize<span class="w"> </span>--size<span class="w"> </span><span class="m">2048</span><span class="w"> </span>foo</span>
</pre></div></div></section>
<section id="id9">
<h3>减小块设备映像的尺寸<a class="headerlink" href="#id9" title="Permalink to this heading"></a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>resize<span class="w"> </span>--size<span class="w"> </span><span class="m">2048</span><span class="w"> </span>foo<span class="w"> </span>--allow-shrink</span>
</pre></div></div></section>
</section>
<section id="id10">
<h2>删除块设备映像<a class="headerlink" href="#id10" title="Permalink to this heading"></a></h2>
<p>要删除块设备，执行下列命令，把 <code class="docutils literal notranslate"><span class="pre">{image-name}</span></code> 替换成要删除映像的名字：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>rm<span class="w"> </span><span class="o">{</span>image-name<span class="o">}</span></span>
</pre></div></div><p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>rm<span class="w"> </span>foo</span>
</pre></div></div><section id="id11">
<h3>从一个存储池删除块设备<a class="headerlink" href="#id11" title="Permalink to this heading"></a></h3>
<p>要从某存储池中删除一个块设备，执行下列命令，把 <code class="docutils literal notranslate"><span class="pre">{image-name}</span></code> 替换成要删除的映像名、把 <code class="docutils literal notranslate"><span class="pre">{pool-name}</span></code> 替换成要删除映像所在存储池的名字：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>rm<span class="w"> </span><span class="o">{</span>pool-name<span class="o">}</span>/<span class="o">{</span>image-name<span class="o">}</span></span>
</pre></div></div><p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>rm<span class="w"> </span>swimmingpool/bar</span>
</pre></div></div></section>
<section id="id12">
<h3>从一个存储池“延迟删除”块设备<a class="headerlink" href="#id12" title="Permalink to this heading"></a></h3>
<p>要从某一存储池中延迟删除（ defer delete ）一个块设备，执行下列命令，
但需把 <code class="docutils literal notranslate"><span class="pre">{image-name}</span></code> 替换成要放进回收站的映像名、
把 <code class="docutils literal notranslate"><span class="pre">{pool-name}</span></code> 替换成它所在存储池的名字：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>trash<span class="w"> </span>mv<span class="w"> </span><span class="o">{</span>pool-name<span class="o">}</span>/<span class="o">{</span>image-name<span class="o">}</span></span>
</pre></div></div><p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>trash<span class="w"> </span>mv<span class="w"> </span>swimmingpool/bar</span>
</pre></div></div></section>
<section id="id13">
<h3>从存储池删除已延期的块设备<a class="headerlink" href="#id13" title="Permalink to this heading"></a></h3>
<p>要从某一存储池删除已延期的块设备，执行下列命令，
但需把 <code class="docutils literal notranslate"><span class="pre">{image-id}</span></code> 替换成想要删除映像的 ID 、
把 <code class="docutils literal notranslate"><span class="pre">{pool-name}</span></code> 替换成它所在存储池的名字：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>trash<span class="w"> </span>rm<span class="w"> </span><span class="o">{</span>pool-name<span class="o">}</span>/<span class="o">{</span>image-id<span class="o">}</span></span>
</pre></div></div><p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>trash<span class="w"> </span>rm<span class="w"> </span>swimmingpool/2bf4474b0dc51</span>
</pre></div></div><div class="admonition note">
<p class="admonition-title">Note</p>
<ul class="simple">
<li><p>你可以把一个映像移入回收站，即便它有快照、
或正在被克隆品引用着，但不能从回收站删掉。</p></li>
<li><p>你可以用 <code class="docutils literal notranslate"><span class="pre">--expires-at</span></code> 设置延期时间（默认为 <code class="docutils literal notranslate"><span class="pre">now</span></code> ），并且，它的延期时间没到的话是不能删除的，除非你用 <code class="docutils literal notranslate"><span class="pre">--force</span></code> 选项。</p></li>
</ul>
</div>
</section>
</section>
<section id="id14">
<h2>块设备映像的恢复<a class="headerlink" href="#id14" title="Permalink to this heading"></a></h2>
<p>要恢复 rbd 存储池内的一个延期删除块设备，用下列命令，但需把
<code class="docutils literal notranslate"><span class="pre">{image-id}</span></code> 替换成那个映像的 ID ：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>trash<span class="w"> </span>restore<span class="w"> </span><span class="o">{</span>image-id<span class="o">}</span></span>
</pre></div></div><p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>trash<span class="w"> </span>restore<span class="w"> </span>2bf4474b0dc51</span>
</pre></div></div><section id="id15">
<h3>恢复指定存储池里的块设备映像<a class="headerlink" href="#id15" title="Permalink to this heading"></a></h3>
<p>要恢复指定存储池内的一个延期删除块设备，用下列命令，但需把
<code class="docutils literal notranslate"><span class="pre">{image-id}</span></code> 替换成映像的 id 、 <code class="docutils literal notranslate"><span class="pre">{pool-name}</span></code> 替换成存储池名字：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>trash<span class="w"> </span>restore<span class="w"> </span><span class="o">{</span>pool-name<span class="o">}</span>/<span class="o">{</span>image-id<span class="o">}</span></span>
</pre></div></div><p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>trash<span class="w"> </span>restore<span class="w"> </span>swimmingpool/2bf4474b0dc51</span>
</pre></div></div></section>
<section id="id16">
<h3>恢复映像时重命名它<a class="headerlink" href="#id16" title="Permalink to this heading"></a></h3>
<p>在恢复时，你还可以加 <code class="docutils literal notranslate"><span class="pre">--image</span></code> 选项来重命名它。</p>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">rbd<span class="w"> </span>trash<span class="w"> </span>restore<span class="w"> </span>swimmingpool/2bf4474b0dc51<span class="w"> </span>--image<span class="w"> </span>new-name</span>
</pre></div></div></section>
</section>
</section>



<div id="support-the-ceph-foundation" class="admonition note">
  <p class="first admonition-title">Brought to you by the Ceph Foundation</p>
  <p class="last">The Ceph Documentation is a community resource funded and hosted by the non-profit <a href="https://ceph.io/en/foundation/">Ceph Foundation</a>. If you would like to support this and our other efforts, please consider <a href="https://ceph.io/en/foundation/join/">joining now</a>.</p>
</div>


           </div>
           
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="../" class="btn btn-neutral float-left" title="Ceph 块设备" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="../rbd-operations/" class="btn btn-neutral float-right" title="Ceph 块设备运维" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).</p>
  </div>

   

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>